/*
 * @Author: lduoduo
 * @Date: 2021-01-19 17:26:17
 * @Last Modified by: lduoduo
 * @Last Modified time: 2021-04-12 21:31:45
 */
import React, { Suspense } from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import { Spin } from 'antd';

import NestedRouterWrapper, { RouteWithSubRoutes } from '~/components/NestedRouterWrapper';
import App from '~/components/App';

import routes from './routes';
import Home from './Home';

const RenderApp = () => {
  return (
    <App>
      <Router basename={'/'}>
        <Suspense fallback={<Spin size="large" />}>
          <Switch>
            {routes.map((route, idx) => (
              <RouteWithSubRoutes key={idx} {...route} />
            ))}
            <Route component={Home} />
          </Switch>
        </Suspense>
      </Router>
    </App>
  );
};

export default RenderApp;
